package laf.socf.simulator.sensors;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Timer;
import laf.socf.simulator.SensorServer;
import laf.socf.simulator.gui.Robot;

/**
 *
 * @author L.A. Fernando
 */
public class Navigation implements Sensor, ActionListener {

    private Robot robot = null;
    private Timer timer = null;
    private int count;

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public Robot getRobot() {
        return robot;
    }

    public void setRobot(Robot robot) {
        this.robot = robot;
    }

    public Navigation() throws Exception {

    }

    public Navigation(Robot robot, int count) throws Exception {
        this.robot = robot;
        this.count = count;        
        init();
    }

    public void init() throws Exception {
        timer = new Timer(10, this);
        SensorServer.getInstance().exportObject("/server/Navigation" + this.count,
                new NavigationRemote(this.robot, this.timer));
    }

    public void startSensor() {
        //timer.start();
    }

    public void stopSensor() {
        timer.stop();
    }

    public String getSensorName() {
        return "Navigation";
    }

    public void actionPerformed(ActionEvent e) {
        this.robot.moveRobot();
    }


}
